// main.go
package main

import (
	"bytes"
	"encoding/json"
	"fmt"
	"io/ioutil"
	"net/http"
)

type ClientReq struct {
	Input  string `json:"input"`
	Output string `json:"output"`
}

func read_one() {

	//output := "2020第8周:连续一个月自己说努力，看到手机继续看手机，不运动，昨天看一天一夜，小事情不解决，大事情是不可能做到的"
	output := "提高专注：看视频时候，就不要看其他网页，无论是小说还是技术文章，在今天30分钟做到，未来30分钟才能做到"
	//
	url := "http://65.49.221.20:8090/note"
	//url := "http://127.0.0.1:8090/note"

	input := "2"

	reqData := &ClientReq{
		Input: input,

		Output: output,
	}
	bf := bytes.NewBuffer([]byte{})
	jsonEncoder := json.NewEncoder(bf)
	jsonEncoder.SetEscapeHTML(false)
	jsonEncoder.Encode(reqData)
	//fmt.Println("output=", output)
	//fmt.Println("buf=", bf)
	req, err := http.NewRequest("POST", url, bf)

	req.Header.Set("Content-Type", "application/json")

	client := &http.Client{}
	resp, err := client.Do(req)
	if err != nil {
		panic(err)
	}
	defer resp.Body.Close()

	fmt.Println("response Status:", resp.Status)
	fmt.Println("response Headers:", resp.Header)
	body, _ := ioutil.ReadAll(resp.Body)
	fmt.Println("response Body:", string(body))
}

func SendMsgToWechat() {

	url := "https://sc.ftqq.com/SCU90598T2b431a055e06a253e8bb5ccaef7214ce5e76dc4584592.send"
	url += "?text="
	url += "每天六点固定流程起床：冥想,洗刷，朗读"
	//url += "& desp="
	//msg = url.QueryEscape(msg)
	//url += msg
	req, err1 := http.NewRequest("GET", url, nil)
	if err1 != nil {
		fmt.Println(err1)
		panic(err1)
	}

	req.Header.Set("Content-Type", "application/x-www-form-urlencoded")

	client := &http.Client{}
	resp, err := client.Do(req)
	if err != nil {
		fmt.Println(err)
		panic(err)
	}
	defer resp.Body.Close()

	fmt.Println("response Status:", resp.Status)
	fmt.Println("response Headers:", resp.Header)
	body, _ := ioutil.ReadAll(resp.Body)
	fmt.Println("response Body:", string(body))
}
func main() {

	SendMsgToWechat()
}
